import request from '@/utils/request';
export const serviceHead = '/base-service'; // 项目前缀

/**
 * 上传单个文件
 * @param params
 * @returns {*}
 */
export function uploadFile (params) {
  return request({
    url: `${serviceHead}/file/uploadFile`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    loading: true,
    data: params
  });
};

/**
 * 上传单个大文件
 * @param params
 * @returns {*}
 */
export function uploadMaxFile (params) {
  return request({
    url: `${serviceHead}/file/uploadMaxFile`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    timeout: 10 * 60 * 1000,
    loading: true,
    data: params
  });
};

/**
 * 上传单个图片(可自定义水印)
 * @param params
 * @returns {*}
 */
export function uploadPic (params) {
  return request({
    url: `${serviceHead}/file/uploadPic`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    loading: true,
    data: params
  });
};

/**
 * 上传多张图片
 * @param params
 * @returns {*}
 */
export function uploadPics (params) {
  return request({
    url: `${serviceHead}/file/uploadPics`,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    method: 'post',
    loading: true,
    data: params
  });
};

/**
 * 根据ids删除图片
 * @param params
 * @returns {*}
 */
export function delFileByIds (params) {
  return request({
    url: `${serviceHead}/file/delFileByIds`,
    method: 'post',
    loading: false,
    data: params
  });
};

/**
 * 根据urls删除图片
 * @param params
 * @returns {*}
 */
export function delFileByUrls (params) {
  return request({
    url: `${serviceHead}/file/delFileByUrls`,
    method: 'post',
    loading: false,
    data: params
  });
};

/**
 * 根据urls批量下载文件ZIP
 * @param params
 * @returns {*}
 */
export function batchDownload (params) {
  return request({
    url: `${serviceHead}/file/downloadZip`,
    method: 'post',
    loading: false,
    responseType: 'blob',
    data: params
  });
};